/**
 * 个性化设置
 */
 const Usersetting = {
    state: {
      setting: {
        theme: 'dark',                // 导航栏主题
        uniqueOpened: true,       // 是否开启手风琴模式
        showMenuButton: true,         // 是否显示菜单展开按钮
        showCrumbs: true,         // 是否显示全局面包屑
        themeModel: 'white',           // 主题模式
        showAvatar: true,           // 是否显示头像
      },
       
      showWorkTab:  JSON.parse(window.sessionStorage.getItem('showWorkTab') || true),  //是否显示历史标签,为了防止刷新页面时，vuex被重新初始化，showWorkTab就变为true，所以使用缓存
      // 用户选择的基地信息
      BaseInfo: JSON.parse(window.sessionStorage.getItem('BaseInfo') || '{}'),

      // 用户选择的加工厂信息
      SlaughterInfo: JSON.parse(window.sessionStorage.getItem('SlaughterInfo') || '{}'),

      // 用户选择的加工厂信息
      ProcessInfo: JSON.parse(window.sessionStorage.getItem('ProcessInfo') || '{}'),

      // 基地对应的所有鸽棚信息
      AllDovecoteInfo: JSON.parse(window.sessionStorage.getItem('AllDovecoteInfo') || '[]'),

      // 用户选择的鸽棚
      CurrentDovecote: JSON.parse(window.sessionStorage.getItem('CurrentDovecote') || '{}'),
    },
    
    getters: {
      setting: (state) => state.setting
    },
    
    mutations: {
      // 所选基地
      setBase(state, currentBaseInfo) {
        state.BaseInfo = currentBaseInfo;
        window.sessionStorage.setItem('BaseInfo', JSON.stringify(currentBaseInfo))
      },

      // 所选加工厂
      setSlaughter(state, currentSlaughterInfo) {
        state.SlaughterInfo = currentSlaughterInfo
        window.sessionStorage.setItem('SlaughterInfo', JSON.stringify(currentSlaughterInfo))
      },

      // 所选加工厂
      setProcess(state, currentProcessInfo) {
        state.ProcessInfo = currentProcessInfo
        window.sessionStorage.setItem('ProcessInfo', JSON.stringify(currentProcessInfo))
      },

      // 基地对应的鸽棚编号
      setAllDovecoteInfo(state, AllDovecoteInfo) {
        state.AllDovecoteInfo = AllDovecoteInfo
        window.sessionStorage.setItem('AllDovecoteInfo', JSON.stringify(AllDovecoteInfo))
      },

      // 设置用户选择的鸽棚编号
      setCurrentDovecote(state, CurrentDovecote) {
        state.CurrentDovecote = CurrentDovecote;
        window.sessionStorage.setItem('CurrentDovecote', JSON.stringify(CurrentDovecote))
      },

      // 设置主题
      setUpTheme(state, theme) {
        state.setting.theme = theme
      },
      // 设置菜单是否为手风琴模式
      setLeftMenuUniqueOpened(state, e) {
        state.setting.uniqueOpened = e.show
      },
      // 显示侧边栏折叠按钮
      setLeftMenuButton(state, e) {
        state.setting.showMenuButton = e.show
      },
      // 是否显示面包屑导航
      setLeftMenuCrumbs(state, e) {
        state.setting.showCrumbs = e.show
      },
      // 主题模式
      setThemeModel(state, theme) {
        state.setting.themeModel = theme
      },
      // 是否显示用户头像
      setshowAvatar(state,e) {
        state.setting.showAvatar = e.show
      },
      //是否显示菜单
      setshowWorkTab(state,e) {
        state.showWorkTab = e;
      }
    },
    
    actions: {
      setUpTheme ({commit}, e) {
        commit('setUpTheme', e)
      },
      setLeftMenuUniqueOpened({commit}, e) {
        commit('setLeftMenuUniqueOpened', e)
      },
      setLeftMenuButton({commit}, e) {
        commit('setLeftMenuButton', e)
      },
      setLeftMenuCrumbs({commit}, e) {
        commit('setLeftMenuCrumbs', e)
      },
      setThemeModel({commit}, e) {
        commit('setThemeModel', e)
      },
      setshowAvatar({commit}, e) {
        commit('setshowAvatar', e)
      }
    }
  }
  
  
  export default Usersetting